Camera = class('Camera', Entity):include(Stateful)

function Camera:initialize()

	Entity.initialize(self)

	self.x = 0
	self.y = 0
	self.scaleX = 1
	self.scaleY = 1
	self.rotation = 0

	self.layers = {}

	self:gotoState('default')

end

function Camera:newLayer(scale, func, old_self)
	table.insert(self.layers, { draw = func, scale = scale, old_self = old_self })
	table.sort(self.layers, function(a,b) return a.scale < b.scale end)
end

function Camera:draw_layers()
	local bx, by = self.x, self.y

	for _, v in ipairs(self.layers) do
		self.x = bx * v.scale
		self.y = by * v.scale
		self:draw()
		v.draw(v.old_self)
		self:pop()
	end
end

require'src.camera_states.default'